﻿@using BlueLotus7.ArchiveSystem.Common;
@using BlueLotus7.Eden.KB.Models;
@using BlueLotus7.Eden.Web.Models;
@using BlueLotus7.Eden.Web;
@model DomainScope
@{
    string panelId = Helper.GeneratePanelId("domainScope", Model);
    ViewFlags flags = ViewBag.Flags;
    bool canEdit = false, showOKButton = false;
    if (flags != null)
    {
        canEdit = flags[ViewFlags.CanEditFlag];
        showOKButton = flags[ViewFlags.ShowOKButtonFlag];
    }

    DomainScopeTypeListControlModel domainScopeTypeListControlModel = new DomainScopeTypeListControlModel();
    domainScopeTypeListControlModel.SelectedValue = Model == null ? null : ((int)Model.Type).ToString();
}
<div id="@(panelId)" key="@(Model == null ? string.Empty : Model.Key.ToString())" class="domainScopePanel">
    <div class="field" name="Name">
        <label>
            Name:
        </label>
        <span class="readonly">@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Name))
        </span><span class="edit">
            <input type="text" value="@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Name))" />
        </span>
    </div>
    <div class="field" name="Code">
        <label>
            Code:
        </label>
        <span class="readonly">@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Code))
        </span>
        @{
            if (Model == null)
            {
            <text> <span class="edit">
                <input type="text" value="@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Code))" />
            </span>
            </text>
            }
        }
    </div>
    <div class="field" name="Type">
        <label>
            Type:
        </label>
        <span class="readonly">@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Type))
        </span><span
            class="edit" value="@(Model == null ? string.Empty : ((int)Model.Type).ToString())">
            @Html.Partial("ControlView/DomainScopeTypeListControlView", domainScopeTypeListControlModel)
        </span>
    </div>
    <div class="field" name="Description">
        <label>
            Description:
        </label>
        <span class="readonly">@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Description))
        </span><span class="edit">
            <textarea>@(Model == null ? string.Empty : Helper.ConvertToHtmlDisplayString(Model.Description))</textarea>
        </span>
    </div>
    <div class="actionPanel">
        @{
            if (showOKButton)
            {
            <text> <a class="button btn-ok">OK</a></text> 
            }

            if (canEdit)
            {
            <text> <a class="button btn-edit">Edit</a><a class="button btn-submit">Save</a><a
                class="button btn-cancel">Cancel</a>
            </text> 
            }
        }
    </div>
</div>
@(Html.Raw(Helper.GenerateEntityJsonObject(Model, panelId)))
<script type="text/javascript">
    $(document).ready(function () {
        initBtnForDomainScope();
    });
</script>
